package Day05;

public class Text2 {
    //实现一个方法 avg, 以数组为参数,
    // 求数组中所有元素的平均值(注意方法的返回值类型).
    public static void main(String[] args) {
        int[] a = {1,2,3};
        System.out.println(avg(a));
    }


    public static int avg(int[] a){
        int sum = 0;
        int avg = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i];
        }
        avg = sum / a.length;
        return avg;

    }
}
